<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8">
<title>模拟配置管理 |模拟新增配置管理</title>
<@fm.header />
<style>
.provinceClass label {
	font-size: 12px;
	float:left;
	margin:2px;
	width:80px;
	height:20px;
}
</style>
</head>
<body>
<div class="easyui-layout" style="text-align: center; height: 270px;" fit="true">
	<div region="center" border="false" style="padding: 10px; background: #fff; border: 1px solid #ccc;">
	<form id="ff" method="post" enctype="multipart/form-data">
		
	<input type="hidden" name="isDelete"   value=1 />
	<input type="hidden" name="mark"   value=${config.mark} />
	<input type="hidden" name="id"   value=${config.id} />
	    <table>
	        <tr>
	            <td><label for="channelName">渠道名称:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="channelName"   value=""></input></td>
	            &nbsp;&nbsp;&nbsp;&nbsp;
	            <td><label for="apkName">apk名称:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="apkName"  value=""></input></td>
	        </tr>
	          <tr>
	            <td><label for="registerActivity">registerActivity:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="registerActivity" value=${config.registerActivity} ></input>
	            <td><label for="fileFilter">文件过滤:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="fileFilter" value=${config.fileFilter} ></input>
	        </tr>
	        <tr>
	         <td><label>基地</label></td>
	            <td> 
		            <input id="cc" class="easyui-combobox" style="width: 155px;" name="base" data-options="
						required:true,
						url:'/base/content?defaultValues=${config.base}',
						method:'get',
						valueField:'id',
						textField:'baseName'" />
	    	 </td>
	            <td><label for="smsId">短信接口</label></td>
	            <td> <select class="easyui-combobox" name="smsId" panelHeight="auto" style="width:155px"  value=${config.smsId} data-options="required:true">
		                <option value="1"<#if config.smsId?exists && config.smsId == 1>selected</#if>>中移统一认证</option>
	                	<option value="2"<#if config.smsId?exists && config.smsId == 2>selected</#if>>咪咕一键登录</option>
						<option value="3"<#if config.smsId?exists && config.smsId == 3>selected</#if>>中移IMSI登录</option>
						<option value="4"<#if config.smsId?exists && config.smsId == 4>selected</#if>>咪咕IMSI登录</option>
		            </select>
	    	 </td>
	        </tr>
	         <tr>
	            <td><label for="carrier">运营商</label></td>
	            <td>
	            	<input type="checkbox" name="carrierCheck" value="2" >移动</input>
	            	<input type="checkbox" name="carrierCheck" value="1" >联通</input>
	            	<input type="checkbox" name="carrierCheck" value="0" >电信</input>
	            	<input id="carrier" type="hidden" name="carrier" value=${config.carrier} >
	            </td>
	            
	             <td><label for="isFill">是否补量包</label></td>
	             <input type="hidden" name="isFill" id="isFill"  value=${config.isFill} ></input>
		       <td>      	<label><input type="checkbox"  id="isFillCheck" > </label>          </td>
	        </tr>
	         <tr>
            <td><label for="isBrush">是否拉活包</label></td>
                            <input type="hidden" name="isBrush" id="isBrush" value=${config.isBrush}></input>
               <td>         <label><input type="checkbox"  id="isBrushCheck" > </label>          </td>
            <td><label for="logLevel">日志级别</label></td>
                <td>
                    <select class="easyui-combobox" name="logLevel" panelHeight="auto" style="width:155px" value=${config.logLevel} data-options="required:true">
                        <option value="3"<#if config.logLevel?exists && config.logLevel == 3>selected</#if>>ERROR</option>
                        <option value="2"<#if config.logLevel?exists && config.logLevel == 2>selected</#if>>WARN</option>
                        <option value="1"<#if config.logLevel?exists && config.logLevel == 1>selected</#if>>INFO</option>
                        <option value="0"<#if config.logLevel?exists && config.logLevel == 0>selected</#if>>DEBUG</option>
                    </select>
                </td>
            </tr>
	         <tr>
	             <td><label for="retent24Filter">留存顺序执行</label></td>
	             <input type="hidden" name="retent24Filter" id="retent24Filter"  value=${config.retent24Filter} ></input>
		       <td>      	<label><input type="checkbox"  id="isRetent24Filter" > </label>          </td>
		       
		       
		        <td><label for="andriodVer">指定andriod版本</label></td>
	            <td><input id="andriodVer" type="text" name="andriodVer" value=${config.andriodVer}></input></td>
	            
	        </tr>
	         
	        <tr>
	        <td><label for="sendType">短信发送类型</label></td>
	            <td>
	            <select class="easyui-combobox" name="sendType" panelHeight="auto" style="width:155px" data-options="required:true">
	            		<option value="1"<#if config.sendType?exists && config.sendType == 1>selected</#if>>文本发送</option>
	                	<option value="2"<#if config.sendType?exists && config.sendType == 2>selected</#if>>数据类型发送</option>
		            </select>
	            </td>
	             <td><label for="daylimit">日限</label></td>
	            <td><input id="daylimit" type="text" name="daylimit" value=${config.daylimit}></input></td>
	        <tr>
	        
	        <tr>
	        	<td><label for="installRate">预安装比例</label></td>
	            <td><input id="installRate" type="text" name="installRate" value=${config.installRate}></input></td>
	            <td><label for="syncUrl">数据同步接口</label></td>
	            <td><input id="syncUrl" type="text" name="syncUrl" value=${config.syncUrl}></input></td>
	        </tr>
	        
	        <tr>
	            <td><label for="apkUpload">apk:</label></td>
	            <td colspan=3><input type="file" name="file" id="apk"></input></td>
	        </tr>
	        <tr>
	            <td><label for="addJar">新增jar包:</label></td>
	            <td colspan=3>
	                <input id="jarPath" type="text" readonly="readonly" style="width:200px" name="addJarPath" value="${config.addJarPath}"></input>
	            </td>
	        </tr>
	         <tr>
	            <td><label for="retentJar">留存jar包:</label></td>
	            <td colspan=3>
	                <input id="jarPath" type="text" readonly="readonly" style="width:200px" name="retentJarPath" value=${config.retentJarPath}></input>
	            </td>
	        </tr>
	        <tr>
	            <td><label for="addScript">新增脚本:</label></td>
	            <td colspan=3>
	            	<input id="addScriptPath" type="text" readonly="readonly" style="width:200px" name="addScriptPath" value=${config.addScriptPath} ></input>
	            </td>
	        </tr>
	        <tr>
	            <td><label for="retentScript">留存脚本:</label></td>
	            <td colspan=3>
	            	<input id="retentScriptPath" type="text" readonly="readonly" style="width:200px" name="retentScriptPath" value=${config.retentScriptPath} ></input>
	            </td>
	        </tr>
	        <tr>
                <td><label for="sysPatch">sysPatch:</label></td>
                <td colspan=3>
                    <input  id="sysPatch" type="text" readonly="readonly" style="width:200px" name="sysPatch"  value=${config.sysPatch}></input>
                </td>
            </tr>
            <tr>
                <td><label for="selfFile">selfFile:</label></td>
                <td colspan=3>
                    <input  id="selfFile" type="text" readonly="readonly" style="width:200px" name="selfFile"  value=${config.selfFile}></input>
                </td>
            </tr>
	         <tr>
	            <td><label for="isNewUserLimit">新增分时段:</label></td>
	            <td> <select class="easyui-combobox" name="isNewUserLimit" panelHeight="auto" style="width:155px" data-options="required:true">
	                	  <option value="0" <#if config.isNewUserLimit?exists && config.isNewUserLimit == 0>selected</#if>>否</option>
	             	 	  <option value="1" <#if config.isNewUserLimit?exists && config.isNewUserLimit == 1>selected</#if>>是</option>
		            </select></input></td>
	            <td><label for="isRetentLimit">留存分时段:</label></td>
	            <td> <select class="easyui-combobox" name="isRetentLimit" panelHeight="auto" style="width:155px" data-options="required:true">
	             			<option value="0" <#if config.isRetentLimit?exists && config.isRetentLimit == 0>selected</#if>>否</option>
	              			<option value="1" <#if config.isRetentLimit?exists && config.isRetentLimit == 1>selected</#if>>是</option>
		            </select></td>
	        </tr>
	          <tr>
	            <td><label for="sysVerId">系统版本号:</label></td>
	            <td colspan="3"><input id="sysVerId" class="easyui-combogrid" style="width: 400px;height: 22px;" name="sysVer" data-options="
						panelHeight: '150',
						multiple:true,
						multiline:true,
						url:'/simulator/verList?mark=${config.mark}&verType=1',
						method:'get',
						idField: 'ver',
            			textField: 'ver',
						columns: [[
							{field:'ver',title:'版本号',width:30},
			            ]],
            			fitColumns: true 
						"/>
	            </td>		
	        </tr>	
	       
	        <tr>
 	            <td><label for="interceptId">拦截策略:</label></td>
	            <td colspan="3"><input id="interceptId" class="easyui-combogrid" style="width: 400px;height: 28px;" name="interceptId" data-options="
						panelWidth: 400,
						panelHeight: '150',
						multiple:true,
						multiline:true,
						url:'/interceptInfo/content?defaultValues=${config.interceptId}',
						method:'get',
						idField: 'id',
            			textField: 'msgContent',
						columns: [[
							{field:'id',title:'编号',width:30},
			                {field:'msgContent',title:'拦截策略',width:150},
			                {field:'regexContent',title:'正则表达式验证码',width:120}
			            ]],
            			fitColumns: true 
						"/>
	            </td>
	        </tr>	  
	         <tr>
	            <td><label for="packageName">指定包名</label></td>
	            <td colspan="3"><input class="easyui-validatebox"  type="text" style="width:400px" name="packageName" ></input>
	        </tr> 
	        <tr>
                <td><label for="maxTaskTime">任务最长时间</label></td>
                <td colspan="3"><input class="easyui-validatebox"  type="text" style="width:400px" name="maxTaskTime" value=${config.maxTaskTime}></input>
            </tr>

            <tr>
                <td><label for="displayCallers">displayCallers</label></td>
                <td colspan="3"><input class="easyui-textbox" data-options="multiline:true" style="width:500px" name="displayCallers" value="${config.displayCallers}"></input>
            </tr>
	    </table>
	</form>
	</div>
	<div region="south" border="false" style="text-align: center; padding: 5px 5px 5px 0;">
	    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="add()">提交</a>
	    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm();">重置</a>
	</div>
</div>

<script>

	$(function(){
		$('#interceptId').combogrid('setValues',[<#list interceptList as i>'${i.id}',</#list>]);
		$('#sysVerId').combogrid('setValues',[<#list sysVerList as i>'${i.sysVer}',</#list>]);
		
		if($("#retent24Filter").val()==1){
			$("#isRetent24Filter").attr("checked","checked");
		}
		
		if($("#isFill").val()==1){
			$("#isFillCheck").attr("checked","checked");
		}
		
		if($("#isBrush").val()==1){
            $("#isBrushCheck").attr("checked","checked");
        }
        
		var val = $("#carrier").val().split(",");
	    var groupCheckbox=$("input[name='carrierCheck']");
	    for(i=0;i<groupCheckbox.length;i++){
	    	for(j=0;j<val.length;j++){
		         if(groupCheckbox[i].value == val[j]){
		             groupCheckbox[i].checked = true;
		          }
	        }
	    }
		
	});
	
	$("#isFillCheck").on('click',function(){
		if ($("#isFillCheck").is(':checked')) {
			$("#isFill").val(1);
		} else {
			$("#isFill").val(0);
		}
	})
	
   $("#isBrushCheck").on('click',function(){
        if ($("#isBrushCheck").is(':checked')) {
            $("#isBrush").val(1);
        } else {
            $("#isBrush").val(0);
        }
    })
    
	$("#isRetent24Filter").on('click',function(){
		if ($("#isRetent24Filter").is(':checked')) {
			$("#retent24Filter").val(1);
		} else {
			$("#retent24Filter").val(0);
		}
	})
	

function add() {
	$('#ff').form(
	    'submit',
	    {
			url : '/apkconfig/saveCopyConfig',
			onSubmit : function() {
				var apkName = $('#apk').val();
				var jarName = $('#jar').val();
				var addScript=$('#addScript').val();
				var retentScript=$('#retentScript').val();
				if (apkName.lastIndexOf('.apk') < 0) {
					top.showMsg(market.content.title, '上传文件必须为.apk文件', alert);
					return false;
				}
				/*if (addScript==null || addScript=='') {
					top.showMsg(market.content.title, '新增脚本文件没有上传', alert);
					return false;
				}
				if (retentScript==null || retentScript=='') {
					top.showMsg(market.content.title, '留存脚本文件没有上传', alert);
					return false;
				}*/
			 	var f_str = '';
				var groupCheckbox=$("input[name='carrierCheck']");
			    for(i=0;i<groupCheckbox.length;i++){
			        if(groupCheckbox[i].checked){
			            var val =groupCheckbox[i].value;
						f_str +=val+",";
			        }
			    }
			    $('#carrier').val(f_str)
				return $(this).form('enableValidation').form('validate');
			},
			success : function(data) {
				showProcess(false);
				var data = eval("(" + data + ")");
				if (data.return_code == '1') {
					top.showMsg(market.content.title, data.return_msg, alert);
					if (parent !== undefined) {
						if ($.isFunction(parent.reloadParent)) {
							parent.reloadParent.call();
							parent.closeMyWindow();
						} else {
							parent.$("#tt").datagrid('reload');
							parent.closeMyWindow();
						}
					}
				}else if(data.return_code == '10'){
					$.messager.alert(market.content.title, data.return_msg);
					if (parent !== undefined) {
						if ($.isFunction(parent.reloadParent)) {
							parent.reloadParent.call();
							parent.closeMyWindow();
						} else {
							parent.$("#tt").datagrid('reload');
							parent.closeMyWindow();
						}
					}
				} else {
					$.messager.alert(market.content.title, data.return_msg);
				}
			},
			onLoadError : function() {
				showProcess(false);
				$.messager.alert(market.content.title, market.content.networkError);
			}
		}); 
}
</script>
</body>
</html>